"""
主题: 创建装饰器时保留函数元信息
问题: 你写了一个装饰器作用在某个函数上，但是这个函数的重要的元信息比如名字、文档字符串、注解和参数签名都丢失了。
提示 : 
"""

import time
from functools import wraps


def timethis(func):
    """
    Decorator that reports the execution time.
    """

    @wraps(func)
    def wrapper(*args, **kwargs):
        start = time.time()
        result = func(*args, **kwargs)
        end = time.time()
        print(func.__name__, end - start)
        return result

    return wrapper


@timethis
def countdown(n: int):
    """
    Counts down
    """
    while n > 0:
        n -= 1

def countdown1(n: int):
    """
    Counts down
    """
    while n > 0:
        n -= 1

def recipe1():
    print(f"{countdown.__name__ = }")
    print(f"{countdown.__doc__ = }")
    print(f"{countdown.__annotations__ = }")
    from inspect import signature

    print(f"{signature(countdown) = }")

def recipe2():
    print(f"{countdown1.__name__ = }")
    print(f"{countdown1.__doc__ = }")
    print(f"{countdown1.__annotations__ = }")
    from inspect import signature

    print(f"{signature(countdown1) = }")

def main():
    print('recipe1'.center(20, '*'))
    recipe1()
    print('recipe2'.center(20, '*'))
    recipe2()

if __name__ == '__main__':
    main()          